package com.mvu.banana.tools;

import java.util.ArrayList;

/**
 * Class description...
 *
 * @author gantz
 */
public class GetMethod extends JavaMethod {
  public GetMethod(JavaClass parent, JavaField field) {
    super(parent);
    withName("get", JavaClass.capitalize(field.name));
    withReturnType(field.type);
    if (!parent._isInterface) {
      if (field.type.collectionName != null) {
        parent.importClass(ArrayList.class);
        addLine("if (", field.name, " == null) {\n      ", field.name,
                " = new ArrayList();\n    }");
      }
      addLine("return ", field.name);
    }
  }
}
